<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: ZLF
  Date: 2020/11/8
  Time: 16:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>$Title$</title>
    <base href="http://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/">
    <script type="text/javascript" src="jquery/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="layer/layer.js"></script>
    <script type="text/javascript">
        $(function () {

            $("#btn1").click(function () {
                $.ajax({
                    "url": "role/get/page/info",   //请求地址
                    "type": "post",       //请求方式
                    "data":{

                    },
                    "dataType": "text", //返回值的处理
                    "success": function (response) {
                        console.log(response)
                    },
                    "error": function (response) {
                        layer.msg(response)
                    }
                });
            });

            $("#btn2").click(function () {

                var array = [1, 2, 3, 4, 5,];
                var a = JSON.stringify(array);

                $.ajax({
                    "url": "test/ajax2",   //请求地址
                    "type": "post",       //请求方式
                    "data": a,              //请求参数,
                    "dataType": "text", //返回值的处理
                    "contentType": "application/json;charset=UTF-8",   //设置请求体的内容类型
                    "success": function (response) {
                        layer.msg(response)
                    },
                    "error": function (response) {
                        layer.msg(response)
                    }
                });
            });

            $("#btn3").click(function () {

                var student = {
                    "m": '张利锋',
                    "n": 122333,
                    "c": ['高数', '语文'],
                    "t": {
                        "k1": 123,
                        "w2": 111
                    }
                };

                var a = JSON.stringify(student);

                $.ajax({
                    "url": "test/ajax3",   //请求地址
                    "type": "post",       //请求方式
                    "data": a,              //请求参数,
                    "dataType": "json", //返回值的处理
                    "contentType": "application/json;charset=UTF-8",   //设置请求体的内容类型
                    "success": function (response) {
                        console.log(response)
                    },
                    "error": function (response) {
                        console.log(response)
                    }
                });
            });
        })
    </script>
</head>
<body>
<a href="admin/to/login/page"><h3>测试</h3></a>
<a href="test"><h3>测试2</h3></a>
<c:forEach items="${admins}" var="admin">
    ${admin.id}
</c:forEach>
<br>
<button id="btn1">测试ajax</button>
<button id="btn2">测试ajax2</button>
<button id="btn3">测试ajax3</button>

</body>
</html>
